*** REPLICATION TOOLKIT ***

* AUTHORS: CIMINELLI DUVAL FURCERI 

* ARTICLE: EMPLOYMENT PROTECTION DEREGULATION AND LABOR SHARES IN ADVANCED ECONOMIES 

* JOURNAL: REVIEW OF ECONOMICS AND STATISTICS

* OUTPUT: FIGURE G2 (ONLINE APPENDIX)

***************************

cd ""

global ci = 1.645

************ PREPARE DATASET **********

run "Do files/Clean dataset"

* Notice: s=2 => layoff rate identification, s=3 EOS identification, s=4 layoff rate X EOS identification

***************************************

* Matrix where to store regression results
quietly sum id_industry
local max = r(max) 
forvalues s = 2/4 {
matrix baseline`s' = J($horizon,3,.)
matrix exclusion`s' = J($horizon,`max',.)
}

*** Regressions
forvalues s = 2/4 {
forvalues i= 1/$horizon {

* Baseline
quietly reghdfe  Y`i' r`s' l1Y l2Y l3Y l4Y l1r`s' l2r`s' l3r`s' l4r`s' t`s' ${f`i'`s'}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
matrix baseline`s'[`i',1] = results[1,1]
matrix baseline`s'[`i',2] = results[1,1] + $ci*results[2,1]
matrix baseline`s'[`i',3] = results[1,1] - $ci*results[2,1]

* Excluding one industry at a time
forvalues c= 1/`max' {
quietly reghdfe  Y`i' r`s' l1Y l2Y l3Y l4Y l1r`s' l2r`s' l3r`s' l4r`s' t`s' ${f`i'`s'} if id_industry != `c', absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
matrix exclusion`s'[`i',`c'] = results[1,1]
}
}

* Variables for graph
matrix coeff`s' = baseline`s'[1...,"c1"]
matrix ci_p`s' = baseline`s'[1...,"c2"]
matrix ci_n`s' = baseline`s'[1...,"c3"]
capture drop coeff`s' ci_p`s' ci_n`s'
svmat coeff`s'
svmat ci_p`s'
svmat ci_n`s'
svmat exclusion`s'
capture drop horizon
egen horizon = group(year) 
replace horizon =. if coeff`s'1==.
}

* Create graph
graph set window fontface "Times New Roman"
forvalues s = 2 / 2 {
graph twoway line coeff`s' ci_p`s' ci_n`s' exclusion`s'* horizon, graphregion(color(white)) ytitle("") xtitle("") ylabel(-4(1)0.5) yline(0, lcolor(black)) xlabel(, nolabels) legend(off) ///
lpattern(solid shortdash shortdash) lwidth (thick thick thick) lcolor(blue red red) subtitle("{bf:Panel A.} Identification through layoff rates") ysize(10) xsize(15)
graph copy g`s', replace
}
forvalues s = 3 / 3 {
graph twoway line coeff`s' ci_p`s' ci_n`s' exclusion`s'* horizon, graphregion(color(white)) ytitle("") xtitle("") ylabel(-4(1)0.5)  yline(0, lcolor(black)) xlabel(, nolabels) legend(off) ///
lpattern(solid shortdash shortdash) lwidth (thick thick thick) lcolor(blue red red) subtitle("{bf:Panel B.} Identification through elasticities of substitution") ysize(10) xsize(15)
graph copy g`s', replace
}
forvalues s = 4 / 4 {
graph twoway line coeff`s' ci_p`s' ci_n`s' exclusion`s'* horizon, graphregion(color(white)) ytitle("") xtitle("") ylabel(-4(1)0.5)  yline(0, lcolor(black)) xlabel(1 "0" 2 "1" 3 "2" 4 "3" 5 "4" 6 "5") legend(off) ///
lpattern(solid shortdash shortdash) lwidth (thick thick thick) lcolor(blue red red) subtitle("{bf:Panel C.} Identification through layoff rates and elasticities of substitution") ysize(10) xsize(15)
graph copy g`s', replace
}

* Combine and save graphs
graph combine g2 g3 g4, cols(1) graphregion(color(white)) ysize(20) xsize(13)
graph export "Figures/G2.png", replace
